from waftools.pebble_test import clar

def build(ctx):
    clar(ctx,
        sources_ant_glob =
            " src/fw/applib/graphics/gtypes.c"
            " src/fw/util/rand/rand.c" \
            " third_party/tinymt/TinyMT/tinymt/tinymt32.c",
        test_sources_ant_glob = "test_clar.c")
    clar(ctx,
        sources_ant_glob = "src/fw/applib/graphics/utf8.c" \
            " tests/fakes/fake_gbitmap_png.c",
        test_sources_ant_glob = "test_utf8.c")

    clar(ctx,
        sources_ant_glob = "src/fw/services/common/i18n/i18n.c" \
            "  src/fw/flash_region/flash_region.c" \
            "  src/fw/flash_region/filesystem_regions.c" \
            "  src/fw/resource/resource.c" \
            "  src/fw/resource/resource_storage.c" \
            "  src/fw/resource/resource_storage_builtin.c" \
            "  src/fw/resource/resource_storage_file.c" \
            "  src/fw/resource/resource_storage_flash.c" \
            "  src/fw/services/normal/filesystem/flash_translation.c" \
            "  src/fw/services/normal/filesystem/pfs.c" \
            "  src/fw/services/normal/filesystem/app_file.c" \
            "  tests/fakes/fake_bootbits.c" \
            "  src/fw/util/crc8.c" \
            "  src/fw/util/legacy_checksum.c" \
            "  src/fw/drivers/flash/flash_crc.c" \
            "  tests/fakes/fake_rtc.c" \
            "  tests/fakes/fake_spi_flash.c" \
            "  tests/fixtures/resources/builtin_resources.auto.c" \
            "  tests/fixtures/resources/pfs_resource_table.c",
        test_sources_ant_glob = "test_i18n.c",
        override_includes=['dummy_board'])

    clar(ctx,
        sources_ant_glob = "src/fw/applib/graphics/utf8.c",
        test_sources_ant_glob = "test_utf8_iterator.c")

    clar(ctx,
        sources_ant_glob = "src/fw/applib/graphics/utf8.c" \
            " src/fw/applib/graphics/framebuffer.c" \
            " src/fw/applib/graphics/gtypes.c" \
            " src/fw/applib/graphics/text_layout.c" \
            " src/fw/applib/fonts/codepoint.c" \
            " tests/fakes/fake_gbitmap_png.c",
        test_sources_ant_glob = "test_char_iterator.c")

    clar(ctx,
        sources_ant_glob = "src/fw/applib/graphics/utf8.c" \
            " src/fw/applib/graphics/framebuffer.c" \
            " src/fw/applib/graphics/gtypes.c" \
            " src/fw/applib/graphics/text_layout.c" \
            " src/fw/applib/fonts/codepoint.c" \
            " tests/fakes/fake_gbitmap_png.c",
        test_sources_ant_glob = "test_word_iterator.c")

    clar(ctx,
         sources_ant_glob = "src/fw/util/rand/rand.c " \
                          "third_party/tinymt/TinyMT/tinymt/tinymt32.c " \
                          "src/fw/process_management/launcher_app_message.c " \
                          "src/fw/util/dict.c " \
                          "tests/fakes/fake_session.c ",
         test_sources_ant_glob="test_launcher_app_message.c")

    clar(ctx,
        sources_ant_glob = "src/fw/applib/graphics/utf8.c" \
            " src/fw/applib/graphics/framebuffer.c" \
            " src/fw/applib/graphics/gtypes.c" \
            " src/fw/applib/graphics/text_layout.c" \
            " src/fw/applib/fonts/codepoint.c" \
            " tests/fakes/fake_gbitmap_png.c",
        test_sources_ant_glob = "test_line_layout.c")

    clar(ctx,
        sources_ant_glob = "src/fw/services/normal/alarms/alarm.c" \
            " src/fw/services/normal/alarms/alarm_pin.c" \
            " src/fw/flash_region/flash_region.c" \
            " src/fw/flash_region/filesystem_regions.c" \
            " src/fw/util/time/time.c" \
            " src/fw/util/time/mktime.c" \
            " src/fw/util/rand/rand.c" \
            " third_party/tinymt/TinyMT/tinymt/tinymt32.c" \
            " src/fw/services/common/cron.c" \
            " src/fw/services/normal/filesystem/flash_translation.c" \
            " src/fw/services/normal/filesystem/pfs.c" \
            " src/fw/services/normal/blob_db/timeline_item_storage.c" \
            " src/fw/services/normal/settings/settings_file.c" \
            " src/fw/services/normal/settings/settings_raw_iter.c" \
            " src/fw/services/normal/timeline/attribute.c" \
            " src/fw/services/normal/timeline/item.c" \
            " src/fw/services/normal/timeline/attributes_actions.c" \
            " src/fw/services/normal/timeline/attribute_group.c" \
            " src/fw/util/crc8.c" \
            " src/fw/util/legacy_checksum.c" \
            " tests/fakes/fake_spi_flash.c",
        test_sources_ant_glob = "test_alarm.c",
        defines=["CAPABILITY_HAS_HEALTH_TRACKING=0"],
        override_includes=['dummy_board'])

    clar(ctx,
        sources_ant_glob = "src/fw/services/normal/alarms/alarm.c" \
            " src/fw/services/normal/alarms/alarm_pin.c" \
            " src/fw/flash_region/flash_region.c" \
            " src/fw/flash_region/filesystem_regions.c" \
            " src/fw/util/time/time.c" \
            " src/fw/util/time/mktime.c" \
            " third_party/tinymt/TinyMT/tinymt/tinymt32.c" \
            " src/fw/services/common/cron.c" \
            " src/fw/services/normal/filesystem/flash_translation.c" \
            " src/fw/services/normal/filesystem/pfs.c" \
            " src/fw/services/normal/blob_db/timeline_item_storage.c" \
            " src/fw/services/normal/settings/settings_file.c" \
            " src/fw/services/normal/settings/settings_raw_iter.c" \
            " src/fw/services/normal/timeline/attribute.c" \
            " src/fw/services/normal/timeline/item.c" \
            " src/fw/services/normal/timeline/attributes_actions.c" \
            " src/fw/services/normal/timeline/attribute_group.c" \
            " src/fw/util/crc8.c" \
            " src/fw/util/legacy_checksum.c" \
            " tests/fakes/fake_clock.c" \
            " tests/fakes/fake_rtc.c" \
            " tests/fakes/fake_spi_flash.c",
        test_sources_ant_glob = "test_alarm_smart.c",
        defines=["CAPABILITY_HAS_HEALTH_TRACKING=1"],
        override_includes=['dummy_board'])

    clar(ctx,
         sources_ant_glob = \
         " src/fw/services/common/battery/battery_state.c " \
         " src/fw/services/common/battery/battery_curve.c " \
         " src/fw/services/common/battery/battery_monitor.c " \
         " tests/fakes/fake_battery.c " \
         " tests/fakes/fake_rtc.c ",
         test_sources_ant_glob = "test_battery_monitor.c",
         defines=['PLATFORM_SNOWY'],
         override_includes=['dummy_board'])

    clar(ctx,
        sources_ant_glob = "src/fw/debug/legacy/debug_db.c",
        test_sources_ant_glob = "test_debug_db.c",
        override_includes=['dummy_board'])

    clar(ctx,
        sources_ant_glob = \
            " src/fw/flash_region/flash_region.c" \
            " src/fw/flash_region/filesystem_regions.c" \
            " src/fw/services/normal/filesystem/flash_translation.c" \
            " src/fw/services/normal/filesystem/pfs.c" \
            " src/fw/services/normal/notifications/alerts_preferences.c" \
            " src/fw/services/normal/notifications/alerts.c" \
            " src/fw/services/normal/settings/settings_file.c" \
            " src/fw/services/normal/settings/settings_raw_iter.c" \
            " tests/fakes/fake_battery.c" \
            " src/fw/util/crc8.c" \
            " src/fw/util/legacy_checksum.c" \
            " tests/fakes/fake_rtc.c" \
            " tests/fakes/fake_spi_flash.c",
        test_sources_ant_glob = "test_alerts.c",
        override_includes=['dummy_board'])

    clar(ctx,
        test_sources_ant_glob = "test_freertos_utils.c")

    clar(ctx,
        sources_ant_glob =
             " src/fw/applib/app_heap_util.c",
        test_sources_ant_glob = "test_heap.c")

    for platform in ['silk', 'snowy']:
        clar(ctx,
             sources_ant_glob =
             " src/fw/debug/default/flash_logging.c"
             " src/fw/flash_region/flash_region.c"
             " tests/fakes/fake_spi_flash.c",
            defines=['DUMA_DISABLED', 'PLATFORM_%s' % platform.upper()],  # DUMA false-positive
            test_sources_ant_glob = "test_flash_logging.c",
            override_includes=['dummy_board'],
            platforms=[platform])

    clar(ctx,
        sources_ant_glob = \
             " src/fw/services/normal/data_logging/dls_main.c" \
             " src/fw/services/normal/data_logging/dls_list.c" \
             " src/fw/services/normal/data_logging/dls_storage.c" \
             " src/fw/services/normal/data_logging/dls_endpoint.c" \
             " src/fw/services/normal/data_logging/dls_syscalls.c" \
             " src/fw/services/common/regular_timer.c" \
             " src/fw/util/shared_circular_buffer.c" \
             " tests/fakes/fake_spi_flash.c" \
             " src/fw/util/crc8.c" \
             " src/fw/util/legacy_checksum.c" \
             " src/fw/flash_region/flash_region.c" \
             " src/fw/flash_region/filesystem_regions.c" \
             " src/fw/services/normal/filesystem/pfs.c" \
             " src/fw/services/normal/filesystem/flash_translation.c" \
             " tests/fakes/fake_session.c" \
             " tests/fakes/fake_rtc.c" \
             " src/fw/applib/data_logging.c" \
             " src/fw/util/rand/rand.c" \
             " third_party/tinymt/TinyMT/tinymt/tinymt32.c",
         test_sources_ant_glob = "test_data_logging.c",
         override_includes=['dummy_board'])

    clar(ctx,
        sources_ant_glob = "src/fw/kernel/memory_layout.c",
        test_sources_ant_glob = "test_memory_layout.c")

    clar(ctx,
       sources_ant_glob = \
           " src/fw/applib/app_exit_reason.c" \
           " src/fw/util/rand/rand.c" \
           " third_party/tinymt/TinyMT/tinymt/tinymt32.c" \
           " src/fw/process_management/process_manager.c" \
           " src/fw/process_management/pebble_process_info.c" \
           " src/fw/process_management/app_manager.c" \
           " src/fw/process_management/pebble_process_md.c" \
           " src/fw/kernel/memory_layout.c" \
           " src/fw/kernel/util/segment.c" \
           " tests/fakes/fake_rtc.c",
       test_sources_ant_glob = "test_app_manager.c",
       override_includes=['dummy_board'])

    clar(ctx,
       sources_ant_glob = \
           " src/fw/process_management/pebble_process_info.c" \
           " src/fw/process_management/process_manager.c",
       test_sources_ant_glob = "test_process_manager.c",
       override_includes=['dummy_board'])

    clar(ctx,
        sources_ant_glob = "src/fw/process_management/pebble_process_info.c",
        test_sources_ant_glob = "test_pebble_app_info.c")

    clar(ctx,
        sources_ant_glob =
            " src/fw/process_management/pebble_process_info.c"
            " src/fw/process_management/pebble_process_md.c",
        test_sources_ant_glob = "test_pebble_process_md.c",
        platforms=['snowy', 'spalding', 'silk', 'robert'])

    clar(ctx,
        sources_ant_glob = "src/fw/applib/graphics/utf8.c" \
            " src/fw/popups/phone_formatting.c",
        test_sources_ant_glob = "test_phone_formatting.c")

    clar(ctx,
         sources_ant_glob=(
             "src/fw/flash_region/filesystem_regions.c "
             "src/fw/flash_region/flash_region.c "
             "src/fw/services/normal/blob_db/pin_db.c "
             "src/fw/services/normal/blob_db/timeline_item_storage.c "
             "src/fw/services/normal/filesystem/flash_translation.c "
             "src/fw/services/normal/filesystem/pfs.c "
             "src/fw/services/normal/settings/settings_file.c "
             "src/fw/services/normal/settings/settings_raw_iter.c "
             "src/fw/services/normal/timeline/attribute.c "
             "src/fw/services/normal/timeline/attribute_group.c "
             "src/fw/services/normal/timeline/attributes_actions.c "
             "src/fw/services/normal/timeline/item.c "
             "src/fw/services/normal/timeline/timeline.c "
             "src/fw/util/crc8.c "
             "src/fw/util/legacy_checksum.c "
             "src/fw/util/rand/rand.c "
             "src/fw/util/time/time.c "
             "third_party/tinymt/TinyMT/tinymt/tinymt32.c "
             "tests/fakes/fake_rtc.c "
             "tests/fakes/fake_spi_flash.c "
             "tests/stubs/stubs_blob_db.c "
         ),
         test_sources_ant_glob="test_timeline_api.c",
         override_includes=['dummy_board'])

    clar(ctx,
        sources_ant_glob = "  src/fw/flash_region/flash_region.c" \
                           "  src/fw/flash_region/filesystem_regions.c" \
                           "  src/fw/system/hexdump.c" \
                           "  src/fw/resource/resource.c" \
                           "  src/fw/resource/resource_storage.c" \
                           "  src/fw/resource/resource_storage_builtin.c" \
                           "  src/fw/resource/resource_storage_file.c" \
                           "  src/fw/resource/resource_storage_flash.c" \
                           "  src/fw/services/normal/filesystem/flash_translation.c" \
                           "  src/fw/services/normal/filesystem/pfs.c" \
                           "  src/fw/services/normal/filesystem/app_file.c" \
                           "  tests/fakes/fake_bootbits.c" \
                           "  src/fw/util/crc8.c" \
                           "  src/fw/util/legacy_checksum.c" \
                           "  src/fw/drivers/flash/flash_crc.c" \
                           "  tests/fakes/fake_rtc.c" \
                           "  tests/fakes/fake_spi_flash.c" \
                           "  tests/fixtures/resources/builtin_resources.auto.c" \
                           "  tests/fixtures/resources/pfs_resource_table.c",
        test_sources_ant_glob = "test_resource.c",
        defines=["CAPABILITY_HAS_MAPPABLE_FLASH=1"],
        override_includes=['dummy_board'])

    clar(ctx,
        sources_ant_glob = " src/fw/util/rand/rand.c" \
                           " third_party/tinymt/TinyMT/tinymt/tinymt32.c" \
                           " src/fw/process_management/app_run_state.c",
        test_sources_ant_glob = "test_app_run_state.c")


    # The following tests rely on the framebuffer, so build for both 1 and 8
    # bit implementations
    templated_sources_ant_glob = \
        "src/fw/applib/graphics/utf8.c" \
        " src/fw/applib/graphics/gbitmap.c" \
        " src/fw/applib/graphics/gtypes.c" \
        " src/fw/applib/graphics/gcolor_definitions.c" \
        " src/fw/applib/graphics/{depth_dir}/framebuffer.c" \
        " src/fw/applib/graphics/framebuffer.c" \
        " src/fw/applib/graphics/graphics.c" \
        " src/fw/applib/graphics/gtransform.c" \
        " src/fw/applib/graphics/bitblt.c" \
        " src/fw/applib/graphics/{depth_dir}/bitblt_private.c" \
        " src/fw/applib/graphics/text_layout.c" \
        " tests/fakes/fake_gbitmap_png.c" \
        " src/fw/applib/fonts/codepoint.c" \
        " src/fw/applib/graphics/graphics_private.c" \
        " src/fw/applib/graphics/graphics_private_raw.c" \
        " src/fw/applib/graphics/graphics_circle.c" \
        " src/fw/applib/graphics/graphics_line.c"

    for platform in ['tintin', 'snowy']:
        bit_depth = 1 if platform == 'tintin' else 8
        depth_dir = '{}_bit'.format(bit_depth)
        sources_ant_glob = templated_sources_ant_glob.format(depth_dir=depth_dir)
        clar(ctx,
             sources_ant_glob=sources_ant_glob,
             test_sources_ant_glob="test_text_layout.c",
             test_name="test_text_layout_%u_bit" % bit_depth,
             defines=["USE_DISPLAY_PERIMETER_ON_FONT_LAYOUT=1"],
             platforms=[platform])

    clar(ctx,
         sources_ant_glob="src/fw/apps/prf_apps/recovery_first_use_app/getting_started_button_combo.c ",
         test_sources_ant_glob="test_getting_started_button_combo.c",
         defines=["RECOVERY_FW"]) # Enable all combos

# vim:filetype=python

